<html> 
<head> 
<title> </title>
<style> 
px {font-family: "Lucida Console", Monaco }
p { font-size:100%; line-height:1.1em; }
body {xfont-style: sans-serif}
body {
color:#333; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:1em; line-height:1.3em; }
a:visited { color:#666; }
h1,h2,h3,h4,h5,h6 { color:#333; font-family:georgia, verdana, sans-serif; }
h1 { font-size:150%; page-break-before:auto;background-color: #aaaaff}
h2 { font-size:143%;color:teal; }
h3 { font-size:134%;color:blue; }
h4 { font-size:120%;color:gray; }
img { max-width: 55em}
p{ padding: 0;margin:0; }
p{ padding-right:1.4em; }
p{ padding-bottom:0.1em; }
p{ padding-top:1em; }
p{ whitespace: pre-wrap; }
h5,h6 { font-size:100% }
a.nav,a:link.nav, a:visited.nav { background-color:#FFF; color:#000; }
XXtable { border:double #000; border-collapse:collapse; }
XXtable { border-collapse:collapse; }
XXtd { border:thin solid #888; }
XXtd { border:none; }
li { margin-bottom:0.5em; }
blockquote { display:block; font-size:100%; line-height:1.1em; margin:0 0 0.5em; padding:0 2.5em; }
pre { background-color:#DDD; font-size:100%; overflow:auto; padding:1em; }
a,li span { color:#000; }
a:hover, a.nav:hover, a:hover math { background-color:#000; color:#FFF; }
#Container { margin:0 10px; text-align:center; background-color: #BBB}
#Content { border-top:none; margin:auto; padding:0.3em; text-align:left; width:100%; max-width:55em; background:#FFF}
span.webName { font-size:.5em; }
textarea#content { font-size: 1em; line-height: 1.125; }
h1#pageName { line-height:1em; margin:0.2em 0 0.2em 0; padding:0; }
.property { color:#666; font-size:100%; }
a.existingWikiWord[title]{ //border: 1px dashed #BBB; }
.byline { color:#666; font-size:1.0em; font-style:italic; margin-bottom:1em; padding-top:1px; } 
</style> 
</head>
<BODY bgcolor=#F0F0F0 text=#000000 link=#0000ff vlink=#C000C0 alink=#ff0000><A NAME=top></A>
<h5><a href="https://github.com/urbanjost/M_strings">[UP]</a></h5>
<div id="Container">
<div id="Content">
<CENTER>
<H1><HR><I>Manual Reference Pages &nbsp;-&nbsp;</I><NOBR>strtok (3m_strings)</NOBR><HR></H1>
</CENTER>
<A name=0>

     <H3>NAME</H3>

</A>
<BLOCKQUOTE>
<B>strtok</B>(3f) - [M_strings:TOKENS] Tokenize a string
(LICENSE:PD)
<P>
</BLOCKQUOTE>
<A name=contents></A><H3>CONTENTS</H3></A>
<BLOCKQUOTE>
<A HREF=#1>Synopsis</A><BR>
<A HREF=#2>Description</A><BR>
<A HREF=#3>Options</A><BR>
<A HREF=#4>Return</A><BR>
<A HREF=#5>Examples</A><BR>
<A HREF=#6>Author</A><BR>
<A HREF=#7>License</A><BR>
</BLOCKQUOTE>
<A name=8>

     <H3>SYNOPSIS</H3>

</A>
<BLOCKQUOTE>
function <B>strtok</B>(source_string,itoken,token_start,token_end,delimiters)
<B>result</B>(<I>strtok_status</I>)
<P>
<PRE>
  ! returned value
  logical                      :: strtok_status
  ! string to tokenize
  character(len=*),intent(in)  :: source_string
  ! token count since started
  integer,intent(inout)        :: itoken
  ! beginning of token
  integer,intent(out)          :: token_start
  ! end of token
  integer,intent(inout)        :: token_end
  ! list of separator characters
  character(len=*),intent(in)  :: delimiters
<P>
</PRE>
</BLOCKQUOTE>
<A name=2>

     <H3>DESCRIPTION</H3>

</A>
<BLOCKQUOTE>
The <B>STRTOK</B>(3f) function is used to isolate sequential tokens in a
string, SOURCE_STRING. These tokens are delimited in the string by
at least one of the characters in DELIMITERS. The first time that
<B>STRTOK</B>(3f) is called, ITOKEN should be specified as zero. Subsequent
calls, wishing to obtain further tokens from the same string,
<TABLE cellpadding=3><!-- tsb: The <B>STRTOK</B>(3f) function is used to isolate sequential tokens in a
 -->
<TR></TR><TR></TR>
<TR valign=top><TD colspan=2>
<B>should pass back in TOKEN_END</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
and ITOKEN until the function result
returns .false.
</TD></TR>
<TR></TR></TABLE>This routine assumes no other calls are made to it using any other
input string while it is processing an input line.
</BLOCKQUOTE>
<A name=3>

     <H3>OPTIONS</H3>

</A>
<BLOCKQUOTE>
<TABLE cellpadding=3>
<TR valign=top><TD colspan=2>
<B>source_string</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
input string to parse
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>itoken</B> </TD><TD valign=bottom>
token count should be set to zero for a new string
</TD></TR>
<TR valign=top><TD colspan=2>
<B>delimiters</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
characters used to determine the end of tokens
</TD></TR>
<TR></TR></TABLE></BLOCKQUOTE>
<A name=4>

     <H3>RETURN</H3>

</A>
<BLOCKQUOTE>
<TABLE cellpadding=3>
<TR valign=top><TD colspan=2>
<B>token_start</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
beginning position in SOURCE_STRING where token was found
</TD></TR>
<TR valign=top><TD colspan=2>
<B>token_end</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
ending position in SOURCE_STRING where token was found
<I>strtok_status</I>
</TD></TR>
<TR></TR></TABLE></BLOCKQUOTE>
<A name=5>

     <H3>EXAMPLES</H3>

</A>
<BLOCKQUOTE>
Sample program:
<P>
<PRE>
    program demo_strtok
    use M_strings, only : strtok
    implicit none
    character(len=264)          :: inline
    character(len=*),parameter  :: delimiters=&#146; ;,&#146;
    integer                     :: ios, itoken, istart, iend
       do ! read lines from stdin until end-of-file or error
          read (unit=*,fmt="(a)",iostat=ios) inline
          if(ios.ne.0)stop
          ! must set ITOKEN=0 before looping on strtok(3f)
          ! on a new string.
          itoken=0
          do while &
          &( strtok(inline,itoken,istart,iend,delimiters) )
             print *, itoken,&
             & &#146;TOKEN=[&#146;//(inline(istart:iend))//&#146;]&#146;,istart,iend
          enddo
       enddo
    end program demo_strtok
<P>
    sample input file
<P>
     this is a test of strtok; A:B :;,C;;
<P>
</PRE>
<BLOCKQUOTE>
sample output file
<TABLE cellpadding=3><!-- tsb: sample output file
 -->
<TR></TR><TR></TR>
<TR valign=top><TD width=6% nowrap>
<B>1</B> </TD><TD valign=bottom>
TOKEN=[this]    2   5
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>2</B> </TD><TD valign=bottom>
TOKEN=[is]      7   8
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>3</B> </TD><TD valign=bottom>
TOKEN=[a]       10  10
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>4</B> </TD><TD valign=bottom>
TOKEN=[test]    12  15
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>5</B> </TD><TD valign=bottom>
TOKEN=[of]      17  18
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>6</B> </TD><TD valign=bottom>
TOKEN=[strtok]  20  25
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>7</B> </TD><TD valign=bottom>
TOKEN=[A:B]     28  30
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>8</B> </TD><TD valign=bottom>
TOKEN=[:]       32  32
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>9</B> </TD><TD valign=bottom>
TOKEN=[C]       35  35
</TD></TR>
<TR></TR></TABLE></BLOCKQUOTE>
</BLOCKQUOTE>
<A name=6>

     <H3>AUTHOR</H3>

</A>
<BLOCKQUOTE>
John S. Urban
</BLOCKQUOTE>
<A name=7>

     <H3>LICENSE</H3>

</A>
<BLOCKQUOTE>
Public Domain
</BLOCKQUOTE>
<P><HR>
<TABLE width=100%><TR> <TD width=33%><I>Nemo Release 3.1</I></TD> <TD width=33% align=center>strtok (3m_strings)</TD> <TD align=right width=33%><I>April 30, 2022</I></TD> </TR></TABLE><FONT SIZE=-1>Generated by <A HREF="http://www.squarebox.co.uk/download/manServer.shtml">manServer 1.08</A> from 0a0d5065-53be-431a-8834-c570204864e0 using man macros.</FONT>
<br><br><center><img src="images/strtok.gif"></center>
</div>
</div>
</body>
</HTML>
